package com.briup.sms.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {
    static final long serialVersionUID = 42L;
    private int code;
    private String message;
    private T data;

    public Result(ResultCode resultCode,T data){
        this.data=data;
        code=resultCode.code();
        message=resultCode.message();
    }
    public static  Result   success(){
        return  new Result(ResultCode.SUCCESS,null);
    }

    public static<T>  Result   success(T data){
        return  new Result(ResultCode.SUCCESS,data);
    }
    public static  Result   error(ResultCode resultCode){
        return  new Result(resultCode,null);
    }
}
